LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-09-2013, 04:28 AM   #1
junkyhlm
Member
 
Registered: Jan 2013
Location: Stockholm, Sweden
Distribution: Debian 6
Posts: 37

Rep: Reputation: Disabled
Question [Ubuntu] How to setup VLAN on same subnet as Ethernet


So this is what i'm trying to do:

I have a physical NIC with dev name eth0 with ip 192.168.1.2 and gateway 192.168.1.1 and I want to setup a VLAN with ip 192.168.1.x and same gateway as eth0.

Setting up the VLAN runs smoothly and i give the VLAN a iface name of eth0.10 and an ip of 192.168.1.69. Now when trying to establish a connection i get an error:

Code:
filserver:~$ sudo ifup eth0.10
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
RTNETLINK answers: File exists
Failed to bring up eth0.10.
So how do I get the VLAN to connect to the internet and what does the error message mean? My guess s that it have something to do with the broadcast.

Please help!

Settings: /etc/network/interfaces

Code:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.1.0
        gateway 192.168.1.1

iface eth0.10 inet static
        address 192.168.1.69
        netmask 255.255.255.0
        gateway 192.168.1.1
I have removed the auto eth0.10 since i dont want to establish it at startup

Settings: ifconfig

Code:
filserver:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1a:4d:5b:02:5c
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:4dff:fe5b:25c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11670807 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22363842 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:833725090 (833.7 MB)  TX bytes:31876321312 (31.8 GB)
          Interrupt:44 Base address:0x4000

eth0.10   Link encap:Ethernet  HWaddr 00:1a:4d:5b:02:5c
          inet addr:192.168.1.69  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:4dff:fe5b:25c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:432 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:41501 (41.5 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4899 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4899 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:697405 (697.4 KB)  TX bytes:697405 (697.4 KB)
Settings: netstat output

Code:
filserver:~$ netstat -anr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0.10
Test: ping output domain name

Code:
filserver:~$ ping -I eth0.10 www.dn.se
PING a1910.g1.akamai.net (23.60.69.161) from 192.168.1.2 eth0.10: 56(84) bytes of data.
From filserver.local (192.168.1.69) icmp_seq=1 Destination Host Unreachable
From filserver.local (192.168.1.69) icmp_seq=2 Destination Host Unreachable
From filserver.local (192.168.1.69) icmp_seq=3 Destination Host Unreachable
^C
--- a1910.g1.akamai.net ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4025ms
pipe 3
Test: ping output ip addr

Code:
filserver:~$ ping -I eth0.10 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.1.2 eth0.10: 56(84) bytes of data.
From 192.168.1.69 icmp_seq=1 Destination Host Unreachable
From 192.168.1.69 icmp_seq=2 Destination Host Unreachable
From 192.168.1.69 icmp_seq=3 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4023ms
pipe 3

Last edited by junkyhlm; 01-09-2013 at 04:34 AM. Reason: Edited IP's
 
Old 01-10-2013, 12:32 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
Quote:
Originally Posted by junkyhlm View Post
I have a physical NIC with dev name eth0 with ip 192.168.1.2 and gateway 192.168.1.1 and I want to setup a VLAN with ip 192.168.1.x and same gateway as eth0.
You do realize that a VLAN is a separate layer 2 network, and that having the same IP subnet assigned to two different physical networks makes little sense?

When you create a VLAN interface, it is bound to a physical interface. Outgoing traffic from the VLAN interface will be encapsulated using 802.1q VLAN tags, so you'll need a 802.1q-capable host, switch or router at the other end for this to work.

Also, having two NICs (one physical, one VLAN) in the same machine does not mean having two gateways. IP addresses are assigned per NIC, gateways are assigned per host. In any case, two NICs belonging to different VLANs cannot share the same gateway, as the NICs belong to different layer 2 networks.

I may be wrong, but I think perhaps VLAN is not what you're looking for. Exactly what are you trying to accomplish?
 
Old 01-10-2013, 12:56 AM   #3
junkyhlm
Member
 
Registered: Jan 2013
Location: Stockholm, Sweden
Distribution: Debian 6
Posts: 37

Original Poster
Rep: Reputation: Disabled
First of all, thank you for your reply.
I am testing a anonymizer service that is using OpenVPN. I'm running a server with rtorrent and apache2 for example and I only want to tunnel the traffic to and from rtorrent through the VPN. I have been testing this alot and concluded that it is a policy routing issue.

First I've setup a VLAN on the 10.x.x.x IP range and everything worked fine, all but one simple little thing: I had no connection to the internet. DOH! i had forgotten the gateway and since i've only have one router/switch (DLink DIR-655) with the assigned ip 192.168.1.1 and from what I've learned the 10.x.x.x range cannot communicate with 192.168.1.0/24 so setting 192.168.1.1 as gateway for the VLAN did'nt work.

Any tips?
 
Old 01-11-2013, 03:12 AM   #4
junkyhlm
Member
 
Registered: Jan 2013
Location: Stockholm, Sweden
Distribution: Debian 6
Posts: 37

Original Poster
Rep: Reputation: Disabled
I've resolved this whit another nic.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] VLAN with 2 Router and 2 Subnet - Is device in different subnet works? velusawme Linux - Networking 2 07-23-2011 10:16 AM
DHCPD: Serve a subnet on a different VLAN. huntkey Linux - Server 4 06-11-2010 02:16 AM
Same subnet VLAN question? NaCo Linux - Networking 3 01-24-2009 11:21 AM
Setup with 2 ethernet interfaces and 2 IP addresses in the same subnet of a class C ursusca Linux - Networking 3 12-25-2008 04:21 PM
ISC dhcp3 (ver. 3.04) vlan setup giving out of improper subnet addresses Valkyr1e Linux - Server 1 07-26-2008 11:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration